#ifndef _SCOPE_H_
#define _SCOPE_H_
#include <QObject>
#include <QFileInfo>
#include "PyName.h"
#include "SimpleNode.h"
#include "ast/VisitorBase.h"

class Scope: public PyName, public VisitorBase
{
    Q_OBJECT
public:
    Scope(Scope* parentScope, const QFileInfo& fileName);
    virtual ~Scope();
public:
    QFileInfo fileName();

    virtual void traverse(const SimpleNodePtr&){}
    virtual void unhandled_node(const SimpleNodePtr&){}

    virtual void visitImport(const ImportPtr &node);
    virtual void visitImportFrom(const ImportFromPtr &node);

    virtual void visitFunctionDef(const FunctionDefPtr &node);
    virtual void visitClassDef(const ClassDefPtr &node);
    virtual void visitAssign(const AssignPtr &node);

    void itemAtPos(int pos);
private:
    Scope *_parentScope;
protected:
    QList<SimpleNodePtr> _nodes;
    QList<Scope*> _childScopes;
    QMultiHash<QString, Scope*> _names;
    QMap<QString, SimpleNodePtr> _attributes;
    QFileInfo _fileName;
};

#endif
